package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyBgColorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class BgColorAdapter extends StkProviderMultiAdapter<MyBgColorBean> {

    public BgColorAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new BgColorProvider());
    }

    private class BgColorProvider extends BaseItemProvider<MyBgColorBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyBgColorBean bean) {
            baseViewHolder.setBackgroundResource(R.id.tvColorItemBg, bean.getRes());
            if (baseViewHolder.getBindingAdapterPosition() == 1) {
                baseViewHolder.setImageResource(R.id.ivColorItemSel, R.drawable.xuanzhongh);
            } else {
                baseViewHolder.setImageResource(R.id.ivColorItemSel, R.drawable.xuanzhongb);
            }
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.ivColorItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivColorItemSel).setVisibility(View.INVISIBLE);
            }
        }
    }
}
